using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Destra.Tools.DACGenerator.Config
{
    public enum DacEntityMethodType
    {
        None = 0,
        Input,
        Output,
        OutputEmbedded,
        ExecuteScalar,
        ExecuteScalarEntity
    }

    public class DacEntityMethodGeneratorConfig
    {
        [XmlAttribute("DacEntityMethodType")]
        public DacEntityMethodType DacEntityMethodType;

        [XmlAttribute("GenerateBusinessLogicClass")]
        public bool GenerateBusinessLogicClass;

        [XmlAttribute("GeneratePredicates")]
        public bool GeneratePredicates;

        [XmlAttribute("EntityName")]
        public string EntityName;

        [XmlAttribute("EntityInterfaces")]
        public string EntityInterfaces;

        [XmlAttribute("CommandOutputVariables")]
        public string CommandOutputVariables;

        [XmlAttribute("CachingEnabled")]
        public bool CachingEnabled;

        [XmlAttribute("CachingType")]
        public string CachingType;

        [XmlAttribute("CachingAdditionalTables")]
        public string CachingAdditionalTables;

        public DacEntityMethodGeneratorConfig()
        {

        }
    }

    public class ParameterConfig
    {
        [XmlAttribute("Name")]
        public string Name;

        [XmlAttribute("SqlDbType")]
        public System.Data.SqlDbType SqlDbType;

        [XmlAttribute("Nullable")]
        public bool Nullable;
    }

    [XmlRoot("DacGeneratorConfig")]
    public class DacGeneratorConfig : GeneratorConfig
    {
        public DacGeneratorConfig()
        {

        }

        [XmlElement("DacEntityMethodGeneratorConfig")]
        public DacEntityMethodGeneratorConfig _DacEntityMethodGeneratorConfig;

        public DacEntityMethodGeneratorConfig DacEntityMethodGeneratorConfig
        {
            get
            {
                if (_DacEntityMethodGeneratorConfig == null)
                {
                    _DacEntityMethodGeneratorConfig = new DacEntityMethodGeneratorConfig();
                    _DacEntityMethodGeneratorConfig.DacEntityMethodType = DacEntityMethodType.None;
                    _DacEntityMethodGeneratorConfig.EntityName = "";
                }
                return _DacEntityMethodGeneratorConfig;
            }
        }

        [XmlElement("RunTimeConnectionStringName")]
        public string RunTimeConnectionStringName;

        [XmlArray("Parameters")]
        [XmlArrayItem("Parameter")]
        public ParameterConfig[] Parameters;

        [XmlElement("CommandTimeout")]
        public int? CommandTimeout;
    }
}
